Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KeyError when building Auth URL #284

Conversation

mrashed-dev
Copy link
Contributor

Description

We were not properly checking the existence of an entry in a dict.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@kraju3
Copy link
Contributor

kraju3 commented Oct 12, 2023

@mrashed-dev This seems to fix the issue.

@mrashed-dev mrashed-dev merged commit fd643d5 into v6.0.0-beta Oct 12, 2023
1 check passed
@mrashed-dev mrashed-dev deleted the TW-2399-v-3-python-sdk-key-errors-are-thrown-due-to-us-accessing-values-in-a-dictionary-that-are-not-present branch October 12, 2023 17:59
mrashed-dev added a commit that referenced this pull request Feb 5, 2024
# Description
This PR is a culmination of all the PRs that contained v6-related development, with formal support for the Nylas API v3. This release is essentially the same as the v6.0.0b9 release found on pypi. Please refer to the readme for a quick start guide on using the new SDK, as well as links to the upgrade doc as well as the SDK reference docs.

# Changelog
* **BREAKING CHANGE**: Python SDK v6 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3
* **BREAKING CHANGE**: Drop support for Python < v3.8
* **BREAKING CHANGE**: Dropped the use of 'Collections' in favor of 'Resources'
* **BREAKING CHANGE**: Removed all REST calls from models and moved them directly into resources
* **BREAKING CHANGE**: Models no longer inherit from `dict` but instead either are a `dataclass` or inherit from `TypedDict`
* **BREAKING CHANGE**: Renamed the SDK entrypoint from `APIClient` to `Client`
* **REMOVED**: Local Webhook development support is removed due to incompatibility
* Rewrote the majority of SDK to be more intuitive, explicit, and efficient
* Created models for all API resources and endpoints, for all HTTP methods to reduce confusion on which fields are available for each endpoint
* Created error classes for the different API errors as well as SDK-specific errors

======================================================================================

* Python SDK Rewrite for API v3 (with Auth, Calendars, and Event support) (#262)

This PR re-writes the Python SDK to be less complex, more human readable, and more intuitive to use. The rewrite also enables support for API v3. The following changes have been made:
- Full rewrite of the SDK, including the HTTP Client
- Dropped support for Python 2.7 and any Python 3.x < 3.8
- Updated all the dependencies to the latest versions
- Support for communicating with API v3 and parsing the response schemas
- Full support for all auth-related methods for API v3
- Full CRUD support for Calendars and Events APIs in API v3

* Add models and typing to resources (#266)

This PR adds models for create and update models and adds typing to all the resources.

Also the following were done:
- Renamed the model package to models
- Cleaned up dependencies
- Add availability and webhook support
- Add generics support
- Change our mixin strategy

* Refactor Auth classes (#267)

This PR aligns the Python SDK to the other SDKs regarding Auth resource functions and models.

* Refactor Error Classes (#268)

This PR ensures the Python SDK has all the models and handling logic required for the different errors that may arise.

* Set up SDK Reference generation (#269)

This PR configures mkdocs to generate an SDK reference for the Python SDK.

* Python SDK v6 Documentation (#270)

This PR finalizes all the in-code documentation, updates the README.md file and adds an UPGRADE.md file.

* v6.0.0 beta 1 Release (#271)

This PR sets up for v6.0.0 beta 1 release.

* Fix API contract for Events (#272)

Fixes to the Event object

* Add None init for Optional fields (#273)

This PR addresses a bug that causes Event deserialization to break. This is because we should init all Optional fields to None.

* v6.0.0 beta 2 Release

* Fix bug when deserializing Union types (#275)

This PR adds in deserialization logic for the polyformic fields.

* Fix bug when deserializing delete response (#277)

For `.destroy()` method we are not using the correct model to deserialize the response to. We just discard it and use `Response` which results in a KeyError.

* v6.0.0 beta 3 Release (#278)

* Improve quickstart examples & documentation overview (#281)

This is everything that tripped me up getting started and would have
helped me orient more quickly without having to go and dig around
in the code overly much.

* Add support for free-busy endpoint (#279)

* Add support for free-busy endpoint

Mostly cribbed off the availability support, though radically stripped
down as free-busy is a great deal simpler.

* debugging

* just work

* fix docs

* fix doc

* rename Error to FreeBusyError

* Change auth build query to point to scope instead of scopes (#283)

Co-authored-by: Kiran Raju <[email protected]@Kirans-MacBook-Pro-2.local>

* Fix KeyError when building Auth URL (#284)

We were not properly checking the existence of an entry in a dict.

* Add Connector support (#292)

This PR adds support for the connector endpoints.

* Nylas Credentials API v3 (#293)

New PR for Credentials API support. Introduced a new class for UpdateRequest and fixed other issues with typing

* v6.0.0 Beta 4 Release (#294)

* Update CHANGELOG.md

* Bump version: 6.0.0b3 → 6.0.0b4

* Changes to calendars and grants models and resources to not fail on decoding. (#300)

Co-authored-by: [email protected] <[email protected]>

* Fix creating a grant/custom auth (#299)

This PR fixes creating a grant by pointing it to the custom auth endpoint.

* v6.0.0 beta 5 release (#302)

* Update CHANGELOG.md

* Bump version: 6.0.0b4 → 6.0.0b5

* document how to enable requests DEBUG logs (#304)

* remove unused imports (#303)

* Add support for Read, Update, and Delete for Messages (#305)

RUD support for Messages API

* Making timezone value and timestamps for Grant optional due to no support in our API's (#306)

* Document events.find() too for comprehensive quickstart (#307)

* v6.0.0 beta 6 Release (#308)

* Update CHANGELOG.md

* Bump version: 6.0.0b5 → 6.0.0b6

* Make "To" Optional (#309)

When sending an email without a To (using bc or bcc), fetching breaks.

* Add Message Send, Drafts, Threads, and Smart Compose APIs support (#310)

This PR builds on #305. Adds the remaining message-related endpoints and models. This PR also brings forward a few breaking changes that alter behaviour to #305:
- In `ListMessageQueryParams` anything that was a list type in the API (to, bcc, etc.) are now List type as well. We then convert these arrays to comma delimited strings fit for the API.
- `Attachments` have moved to `models/attachments.py` as we needed a common space for both `Message` and `Draft` objects to pull from.

* Folders API support (#311)

This PR adds support for the folders API.

* Attachments API Support (#312)

This PR adds support for the Attachments API.

* v6.0.0 beta 7 Release (#314)

Changelog:
* Add Message Send, Drafts, Threads, and Smart Compose APIs support (#310)
* Add support for folders API (#311)
* Add support for attachments API (#312)
* Fix required field for the `Message` model (#309)

* Fix message send/draft create/modify not working properly (#315)

This PR fixes the serialization of outgoing message requests using the multipart formatter. We've also added in a helper function to help with formatting files to attach to a message.

* Fix required fields in Thread (#322)

Fix some optional fields to be able to return a thread

* Move `Grants` to `NylasClient` and custom authentication to `Auth` (#324)

* Move custom auth out of grants to auth

* move grants entry point out of auth to nylasclient

* Update CHANGELOG.md

* Fix issue with multipart attachments throwing KeyError (#319)

* fix attaching files via multipart

* Update CHANGELOG.md

* Fix inaccuracies with Event models (#317)

* Fix inaccuracies with Event models

* fix calendar typo

* timestamps should be int

* Add contact objects

* Add Contact CRUD support

* Add contact group support

* Fixes for contacts api

Found some bugs on AV-1465-3-0-ga-python-sdk-contacts-api so this PR should address them as I have fully tested them.

* Contacts API support (#325)

This PR adds support for the Contacts API.

* Fix incorrect PKCE code challenge generation (#330)

This PR fixes the PKCE code challenge generation; the correct method the API wants is for us to base64 encode the hex string as opposed to base64 encoding resulting hashed bytearray directly. Closes #329. Thanks to @wobeng for reporting and providing the correct code.

Co-authored-by: Welby O. <[email protected]>

* v6.0.0 beta 8 Release (#331)

* linting

* Bump version: 6.0.0b7 → 6.0.0b8

* Update CHANGELOG.md

* Update client.py to add Drafts (#333)

Added the call to Drafts endpoint

* Fix drafts API entrypoint (#334)

* Add support for sending drafts (#336)

This PR adds support for sending drafts.

* Update events.py to add capacity (#335)

Add capacity to the events response

* Changed client_secret to optional for token exchange methods; defaults to API Key now (#337)

client_secret is not required if the API Key used for the SDK and the clientId belong to the same application.

* Python testing framework + fixes (#323)

This PR adds the full testing suite for Python. This also includes the following fixes:
* Changed references to `callback_url` to `webhook_url` to match API
* Fix deserialization issue with `Connector` model
* Fix serialization of query parameters
* Fix typos in folders, threads, code exchange, smart compose, webhook and attachment models
* Fix types in reminder and messages models
* Fix message/draft deserialization in thread model
* Standardized casing for enums

* Fix fields for creating drafts and sending messages (#338)

Fix fields for creating drafts and sending messages.

* Add pylint step and address linting issues (#339)

This PR runs pytest for the first time and fixes all offences (after disabling certain rules), and adds a step to lint to the CI steps.

* v6.0.0 beta 9 Release (#340)

# Changelog
* Add support for sending drafts
* Changed `client_secret` to optional for token exchange methods; defaults to API Key now
* Changed references to `callback_url` to `webhook_url` to match API
* Fix deserialization issue with `Connector` model
* Fix serialization of query parameters
* Fix typos in folders, threads, code exchange, smart compose, webhook and attachment models
* Fix types in reminder and messages models
* Fix message/draft deserialization in thread model
* Standardized casing for enums

* Update CHANGELOG.md

* scrub references to the beta

* Bump version: 6.0.0b9 → 6.0.0

---------

Co-authored-by: Christine Spang <[email protected]>
Co-authored-by: Christine Spang <[email protected]>
Co-authored-by: kraju3 <[email protected]>
Co-authored-by: Kiran Raju <[email protected]@Kirans-MacBook-Pro-2.local>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Blag <[email protected]>
Co-authored-by: Welby O. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants